# -*- coding: utf-8 -*-
from django.db import models
from bd42.utils import form_fields




class CPFModelField(models.Field):
    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = 14
        models.Field.__init__(self, *args, **kwargs)

    def get_internal_type(self):
        return "CharField"

    def formfield(self, **kwargs):
        defaults = {'form_class': form_fields.CPFField}
        defaults.update(kwargs)
        return super(CPFModelField, self).formfield(**defaults)




class CNPJModelField(models.Field):
    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = 18
        models.Field.__init__(self, *args, **kwargs)

    def get_internal_type(self):
        return "CharField"

    def formfield(self, **kwargs):
        defaults = {'form_class': form_fields.CNPJField}
        defaults.update(kwargs)
        return super(CNPJModelField, self).formfield(**defaults)




class CEPModelField(models.Field):
    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = 9
        models.Field.__init__(self, *args, **kwargs)

    def get_internal_type(self):
        return "CharField"

    def formfield(self, **kwargs):
        defaults = {'form_class': form_fields.CEPField}
        defaults.update(kwargs)
        return super(CEPModelField, self).formfield(**defaults)




class PhoneModelField(models.Field):
    def __init__(self, *args, **kwargs):
        kwargs['max_length'] = 14
        models.Field.__init__(self, *args, **kwargs)

    def get_internal_type(self):
        return "CharField"

    def formfield(self, **kwargs):
        defaults = {'form_class': form_fields.PhoneField}
        defaults.update(kwargs)
        return super(PhoneModelField, self).formfield(**defaults)
